/**
 * Created with IntelliJ IDEA
 * Description:
 * User: SEKI TOMOKI
 * Date: 2023-09-17
 * Time: 11:38
 */
public class Solution {
    public int missingNumber(int[] nums) {
        int[] arrayCount = new int[nums.length + 1];
        int ret = -1;
        for(int i = 0; i < nums.length; i ++) {
            int index = nums[i];
            arrayCount[index]++;
        }

        for(int i = 0; i < nums.length + 1; i++) {
            if(arrayCount[i] == 0) {
                ret = i;
            }
        }
        return ret;
    }
}
